const { createProxyMiddleware } = require("http-proxy-middleware");

module.exports = function (app) {
  // mock server
  app.use(
    "/mock",
    createProxyMiddleware({
      target: "http://127.0.0.1:4001",
      secure: false,
      changeOrigin: true,
      pathRewrite: {
        "^/mock/": "/",
      },
    })
  );
  // ruoyi server
  app.use(
    createProxyMiddleware(
      (path) => !path.startsWith("/pine") && !path.startsWith("/maple") && !path.startsWith("/mock"),
      {
        target: "http://192.168.2.25:6680",
        secure: false,
        changeOrigin: true,
      }
    )
  );
};
